import { ADD_COUNTER, ADD_TO_CART } from "./mutationsType";
const actions = {
    addCart (context, payload) {
        // 1.查看是否添加过
        const oldInfo = context.state.cartList.find(item => item.iid === payload.iid)
        // 2.+1或者新添加
        if (oldInfo) {
            context.commit(ADD_COUNTER, oldInfo)
        } else {
            payload.count = 1
            payload.checked = true
            context.commit(ADD_TO_CART, payload)
        }
    }
}

export default actions

